#include "gifview.h"
#include "ui_gifview.h"
#include "gifviewcontroller.h"
#include <QMovie>

CGIFView::CGIFView(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GIFView),
    m_pGif(new QMovie(this))
{
    ui->setupUi(this);
}

CGIFView::~CGIFView()
{
    delete ui;
}

void CGIFView::SetController(CGIFViewController *pController)
{
    m_pController = pController;
}

void CGIFView::ShowGIF(const QString &strPath)
{
    m_pGif->setFileName(strPath);
    ui->m_gif_label->setMovie(m_pGif);
    ui->m_gif_label->setScaledContents(true);
    m_pGif->start();
}

QSize CGIFView::GetScaleSize() const
{
    return QSize(ui->m_scaleWidth_spinBox->value(), ui->m_scaleHeight_spinBox->value());
}

QString CGIFView::GetShowGIFPath() const
{
    return m_pGif->fileName();
}

void CGIFView::on_m_openGIF_pushButton_clicked()
{
    if(!m_pController)
    {
        return;
    }

    m_pController->OpenGIF();
}

void CGIFView::on_m_scaleGIF_pushButton_clicked()
{
    if(!m_pController)
    {
        return;
    }

    m_pController->ScaleGIF();
}

